package com.lcf.test;

import com.lcf.demo.Student;

public class Demo7 {
    public static void main(String[] args) {
//        创建实例化对象
        Student S = new Student();
        // 创建五个 Student 对象
        Student[] students = new Student[5];
        students[0] = new Student("S001", "张三", "男", 20, 85.5);
        students[1] = new Student("S002", "李四", "女", 21, 92.0);
        students[2] = new Student("S003", "王五", "男", 19, 78.0);
        students[3] = new Student("S004", "赵六", "女", 22, 88.5);
        students[4] = new Student("S005", "孙七", "男", 20, 91.0);
//        输出结果
        for (Student student : students) {
            student.displayInfo();
        }

        // 计算Java语言成绩的平均值、最大值和最小值
        double sum = 0;
        double max = students[0].getsJava();
        double min = students[0].getsJava();
        for (Student student : students) {
            double score = student.getsJava();
            sum += score;
            if (score > max) {
                max = score;
            }
            if (score < min) {
                min = score;
            }
        }
        double average = sum / students.length;

        // 输出结果
        System.out.println("Java语言成绩的平均值: " + average);
        System.out.println("Java语言成绩的最大值: " + max);
        System.out.println("Java语言成绩的最小值: " + min);
    }
}





